//
//  CanvasView.m
//  iCodeMacRun
//
//  Created by Andrew Barry on 30/03/09.
//  Copyright 2009 Barry Computer Services. All rights reserved.
//

#import "CanvasView.h"


@implementation CanvasView

- (id)initWithFrame:(NSRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code here.
    }
    return self;
}

-(void) setObject: (jsvalue)o withTarget: (jsvalue) targ withContext: (jscontext *) cx {
	jsaddroot(cx, &obj);
	jsaddroot(cx, &target);
	obj = o;
	target = targ;
	_cx = cx;
}

-(bool) isFlipped {
	return YES;
}

- (void)drawRect:(NSRect)rect {
	jsvalue fn = jsget(_cx, obj, 0, "Paint");
	if (fn && JSVAL_IS_OBJECT(fn)) {
		jsinvoke(_cx, fn, target, nil, 0);
	}
}

@end
